# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=poetry
pkgver=1.1.14
pkgrel=0
pkgdesc="Python3 dependency management and packaging system"
url="https://python-poetry.org"
license="MIT"
arch="noarch"
options="!check" # TODO: add tests
depends="
	python3
	py3-poetry-core
	py3-cleo
	py3-clikit
	py3-crashtest
	py3-requests
	py3-cachy
	py3-requests-toolbelt
	py3-cachecontrol
	py3-pkginfo
	py3-html5lib
	py3-shellingham
	py3-tomlkit
	py3-pexpect
	py3-packaging
	py3-virtualenv
	py3-keyring
	py3-lark-parser
	py3-jsonschema
	"
makedepends="py3-build py3-installer"
source="$pkgname-$pkgver.tar.gz::https://github.com/sdispater/poetry/archive/$pkgver.tar.gz
	fix-packaging-tags.patch
	"

prepare() {
	default_prepare

	# poetry-core excludes files specified in .gitignore (src/ in case of aports)
	# so we need to create a separate git repository
	git init
}

build() {
	python3 -m build --no-isolation --skip-dependency-check --wheel
}

package() {
	python3 -m installer -d "$pkgdir" --compile-bytecode 0 \
		dist/poetry-$pkgver-py2.py3-none-any.whl

	# remove conflicts with files owned by py3-poetry-core (direct dependency of poetry)
	# see: https://github.com/python-poetry/poetry/issues/2800
	local sitedir=$(python3 -c "import site; print(site.getsitepackages()[0])")
	rm "$pkgdir/$sitedir"/poetry/__init__.py \
		"$pkgdir/$sitedir"/poetry/__pycache__/__init__.cpython-*.pyc \
		"$pkgdir/$sitedir"/poetry/json/schemas/poetry-schema.json
}

sha512sums="
0a12e4c592c6d532a5b77eaa782fe419dd02310b8f284d7a2f293658ce4dc2bbed52489ef7bbcf0cc847d729cadcbacef070c24550039314af1b2f2ad5fdb1c9  poetry-1.1.14.tar.gz
392777b21ec45d35eb3df37b9286096520556398c947c7e51f319fee871de0a091870203e20461caacae1b78b0b832ca9305b22332262f3e8b41b0eed596c7af  fix-packaging-tags.patch
"
